package org.quarenden.demo.feign;

import org.quarenden.demo.pojo.MicroService;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@FeignClient(name="micro-service1",fallback = MicroService1FeignClientFallBack.class)
public interface MicroService1FeignClient {
    @RequestMapping(value="/saveMicroService",method = RequestMethod.POST)
    public String saveMicroService(@RequestBody MicroService microService);

    @RequestMapping(value="/{id}",method = RequestMethod.GET)
    public MicroService getMicroService(@PathVariable("id") String id);
}

@Component
class MicroService1FeignClientFallBack implements MicroService1FeignClient{
    @Override
    public String saveMicroService(MicroService microService) {
        return "-1";
    }

    @Override
    public MicroService getMicroService(String id) {
        return null;
    }
}
